package com.oig.sys.workflow.dao;

import com.oig.sys.workflow.entity.TbDataModuleDetail;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;

import java.util.List;

/**
 * @author wuxl
 */
public interface ITbDataModuleDetailDao extends JpaRepository<TbDataModuleDetail, Integer> {

	@Query("from TbDataModuleDetail d where d.id=:id")
	TbDataModuleDetail getDMDById(@Param("id") Integer id);

	TbDataModuleDetail getByDataModuleIdAndColumnField(Integer dataModuleId, String columnField);


	List<TbDataModuleDetail> findAllByDataModuleId(Integer dataModuleId);

	@Query("select d.id from TbDataModuleDetail d where d.id not in(:idList) and d.dataModuleId=:dataModuleId")
	List<Integer> findAllDelId(@Param("dataModuleId") Integer dataModuleId, @Param("idList") List<Integer> idList);


	@Modifying
	@Query("delete from TbDataModuleDetail d where d.id in(:idList)")
	void deleteByIdList(@Param("idList") List<Integer> idList);
}
